package pers.gxm.shiro.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import pers.gxm.shiro.mapper.UserMapper;
import pers.gxm.shiro.pojo.User;
import pers.gxm.shiro.service.UserService;

import java.util.List;

@Service
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements UserService {
    @Autowired
    private UserMapper userMapper;

    @Override
    public User getUserByName(String username) {
        LambdaQueryWrapper<User> userWrapper = new LambdaQueryWrapper<>();
        userWrapper.eq(User::getName,username);
        User user = userMapper.selectOne(userWrapper);
        return user;
    }

    @Override
    public List<String> getUserRoles(String username) {
        return userMapper.getUserRoles(username);
    }

    @Override
    public List<String> getPermissionsByRole(List<String> roles) {
        return userMapper.getPermissionsByRole(roles);
    }
}
